# date:20210209
from typing import List

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        nums = sorted(zip(nums, range(len(nums))),key=lambda x:x[0])
        left, right = 0, len(nums)-1
        flag = nums[left][0] + nums[right][0]
        while(flag != target):
            if flag > target:
                right -= 1
            else:
                left += 1
            flag = nums[left][0] + nums[right][0]
        return [nums[left][1], nums[right][1]]






model = Solution()
nums = [2, 7, 11, 15]
target = 9
print("result: ", model.twoSum(nums, target))

nums = [3,2,4]
target = 6
print("result: ", model.twoSum(nums, target))